package com.cucheng.chatroom.web.controller;

import static org.springframework.web.bind.annotation.RequestMethod.POST;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.cucheng.chatroom.model.vo.ResponseJson;
import com.cucheng.chatroom.service.FileUploadService;

@Controller
@RequestMapping("/chatroom")
public class FileUploadController {

    @Autowired
    private FileUploadService fileUploadService;

    /**
     *@Description: TODO(文件上传) 
     *@Author: wangchengjie
     *@Since: 2019年3月30日下午3:47:46
     *@param file
     *@param request
     *@return
     */
    @RequestMapping(value = "/upload",method = POST)
    @ResponseBody
    public ResponseJson upload(@RequestParam(value = "file",required = true) MultipartFile file,HttpServletRequest request){
        return fileUploadService.upload (file, request);
    }
}
